import { Component, OnInit } from "@angular/core";

@Component({
  selector: "app-footer",
  templateUrl: "./footer.component.html",
  styleUrls: ["./footer.component.scss"]
})
export class AppFooterComponent implements OnInit {
  constructor() { }

  ngOnInit() {
    this.GoBackTop();
  }

  //回到顶部
  // GoBackTop() {
  //   let speed=200;//滑动的速度
  //   window['$']('body,html').animate({ scrollTop: 0 }, speed);
  //   return false;
  // }
  //回到顶部
  GoBackTop() {
    window['$'](document).ready(function ($) {
      // browser window scroll (in pixels) after which the "back to top" link is shown
      var offset = 300,
        //browser window scroll (in pixels) after which the "back to top" link opacity is reduced
        offset_opacity = 1200,
        //duration of the top scrolling animation (in ms)
        scroll_top_duration = 700,
        //grab the "back to top" link
        $back_to_top = window['$']('.cd-top');

      //hide or show the "back to top" link
      window['$'](window).scroll(function () {
        ($(this).scrollTop() > offset) ? $back_to_top.addClass('cd-is-visible') : $back_to_top.removeClass('cd-is-visible cd-fade-out');
        if ($(this).scrollTop() > offset_opacity) {
          // $back_to_top.addClass('cd-fade-out');
        }
      });
      //smooth scroll to top
      $back_to_top.on('click', function (event) {
        event.preventDefault();
        window['$']('body,html').animate({
          scrollTop: 0,
        }, scroll_top_duration
        );
      });

    });
  }
}
